<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <!-- 用于对标签属性进行限制 -->
    <script src="../js/prop-types.js"></script>
</head>

<body>
    <div id="test"></div>
    <script type="text/babel">
       function Person(props){
            const {name,sex,age} = props;           
           return (
               <ul>
                    <li>姓名：{name}</li>
                    <li>性别：{sex}</li>
                    <li>年龄：{age}</li>
                </ul>
           )
       }

       Person.propTypes={
            name:PropTypes.string.isRequired,
            age:PropTypes.number,
            sex:PropTypes.string,
        }
       Person.defaultProps = {
            age:18
        }
       

        ReactDOM.render(<Person name='tom' sex='男' age={9} />, document.getElementById('test'))
        
        // 模拟后台返回的数据
        // const p1 = {
        //     name: "kiki",
        //     sex: '女',
        //     age: 20
        // }
        // ReactDOM.render(<Person {...p1} />, document.getElementById('test2'))


    </script>
</body>

</html>